package com.javakc.mes.basis.mine.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.javakc.mes.basis.area.entity.Area;
import com.javakc.mes.basis.roadway.entity.Roadway;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Getter
@Setter
@Entity
@Table(name = "maintain_mine")
@EntityListeners(AuditingEntityListener.class)
public class MaintainMine {
    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;
    /**
     * 矿井名称
     */
    @NotBlank(message = "矿井名称不能为空")
    private String mineName;
    /**
     * 瓦斯等级
     */
    @NotNull(message = "瓦斯等级不能为空")
    private Integer mineGasGrade;
    /**
     * 设计能力
     */
    @NotNull(message = "设计能力不能为空")
    private Double mineDesignPower;
    /**
     * 投产日期
     */
    @NotNull(message = "投产日期不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date mineProductionTime;
    /**
     * 改造能力
     */
    private Double mineReformPower;
    /**
     * 改造日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date mineReformTime;
    /**
     * 备注
     */
    private String mineRemark;
    /**
     * 煤矿主键
     */
    private Integer collieryId;

    @OneToMany(mappedBy = "mine",fetch = FetchType.EAGER)
    private List<Roadway> roadway = new ArrayList<>();

    @OneToMany(mappedBy = "mine")
    private List<Area> area = new ArrayList<>();
    /**
     * 删除状态
     */
    private Integer deleteFlag;
    /**
     * 创建人
     */
    private Integer createdBy;
    /**
     * 创建时间
     */
    @CreatedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @Column(name = "created_time",updatable = false)
    private Date createdTime;
    /**
     * 更新人
     */
    private Integer updatedBy;
    /**
     * 更新时间
     */
    @LastModifiedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @Column(name = "updated_time",insertable = false)
    private Date updatedTime;


}
